<template>
  <div>

    <el-button type="primary" @click="handleAddEvent">添加按钮</el-button>
    <el-table :data="tableData" style="width: 100%">
      <el-table-column label="日期" width="180">
          <template slot-scope="scope">
            <i class="el-icon-time"></i>
            <span style="margin-left: 10px">{{ scope.row.date }}</span>
          </template>
      </el-table-column>
      <el-table-column></el-table-column>
     <el-table-column label="名字" prop="name"></el-table-column>
     <el-table-column label="操作">
      <template slot-scope="scope">
        <el-button
          size="mini"
          @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
        <el-button
          size="mini"
          type="danger"
          @click="handleDelete(scope.$index, scope.row)">删除</el-button>
      </template>
    </el-table-column>
  </el-table>

  <BaseDialog
    :outerVisible="outerVisible"
    :innerVisible="innerVisible"
    @handleOuterSure="handleOuterSure"
    @handleInderSure="handleInderSure"
    @handleInnerClose="handleInnerClose"
    @handleOuterClose="handleOuterClose"
  />
  </div>
</template>

<script>
import BaseDialog from '@/components/BaseDialog'
import { mapMutations } from 'vuex'
export default {
  components: {
    BaseDialog
  },
  props: {
    tableData: {
      type: Array,
      default() {
        return [{
            date: '2016-05-02',
            name: '王小虎',
            address: '上海市普陀区金沙江路 1518 弄'
          }, {
            date: '2016-05-04',
            name: '王小虎',
            address: '上海市普陀区金沙江路 1517 弄'
          }, {
            date: '2016-05-01',
            name: '王小虎',
            address: '上海市普陀区金沙江路 1519 弄'
          }, {
            date: '2016-05-03',
            name: '王小虎',
            address: '上海市普陀区金沙江路 1516 弄'
          }]
      }
    }
  },
  data() {
    return {
      outerVisible: false,
      innerVisible: false
    }
  },
  methods: {
    ...mapMutations('table', ['SET_SUBMIT']),
    // 添加按钮事件
    handleAddEvent() {
      this.outerVisible = true;
    },
    // 内层确认事件
    handleInderSure() {
      this.outerVisible = false;
      this.innerVisible = false;
      // 点击这个按钮，实现弹出框的提交事件
      console.log(this.$refs.upload)
      this.SET_SUBMIT(true)
    },
    // 内层弹出框取消事件
    handleInnerClose() {
      this.innerVisible = false;
    },
    // 外层取消
    handleOuterClose() {
      this.outerVisible = false;
    },
    // 打开 内层弹出框
    handleOuterSure() {
      this.innerVisible = true;
    },
    handleEdit(index, row) {},
    handleDelete(index, row) {}
  }
}
</script>

<style>

</style>
